
CROSS_COMPILE = aarch64-linux-gnu-
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
OBJCOPY = $(CROSS_COMPILE)objcopy

CFLAGS = -Wall -Wextra -O2 -ffreestanding -nostdlib


LDFLAGS = -g --entry=_start --section-start=.text=0 --section-start=.stack=0x4010000


TARGET = flash_bl0

OBJS = startup.o

all: $(TARGET).bin $(TARGET)_le.bin

$(TARGET).bin: $(TARGET).axf
	$(OBJCOPY) -O binary $< $@

$(TARGET).axf: $(OBJS)
	$(LD) $(LDFLAGS) -o $@ $^

$(TARGET)_le.bin: $(TARGET).bin
	hexdump -v -e '1/1 "%02X" "\n"' $< > $@

%.o: %.S
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	rm -f $(OBJS) $(TARGET).bin $(TARGET)_le.bin $(TARGET).axf	